using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace ResourceBlender_Express {
    /// <summary>
    /// An element used in an application
    /// </summary>
    public class RBElement : INotifyPropertyChanged {
        private int id;
        private string name,
                       bundleID,
                       bundleName,
                       comment;
        private RBApplication application;
        private RBResource resource;

        /// <summary>
        /// Gets or sets the element's application.
        /// </summary>
        /// <value>The element's application.</value>
        public RBApplication Application {
            get { return application; }
            set {
                application = value;
                OnPropertyChanged("Application");
            }
        }
        /// <summary>
        /// Gets or sets the ID.
        /// </summary>
        /// <value>The ID.</value>
        public int ID {
            get { return id; }
            set {
                id = value;
                OnPropertyChanged("ID");
            }
        }
        /// <summary>
        /// Gets or sets the element name.
        /// </summary>
        /// <value>The name.</value>
        public string Name {
            get { return name; }
            set {
                name = value;
                OnPropertyChanged("Name");
            }
        }
        /// <summary>
        /// Gets or sets the ID of the bundle in which this element is used.
        /// </summary>
        /// <value>The bundle ID.</value>
        public string BundleID {
            get { return bundleID; }
            set {
                bundleID = value;
                OnPropertyChanged("BundleID");
            }
        }
        /// <summary>
        /// Gets or sets the name of the bundle in which this element is used.
        /// </summary>
        /// <value>The name of the bundle.</value>
        public string BundleName {
            get { return bundleName; }
            set {
                bundleName = value;
                OnPropertyChanged("BundleName");
            }
        }
        /// <summary>
        /// Gets or sets the comment.
        /// </summary>
        /// <value>The comment.</value>
        public string Comment {
            get { return comment; }
            set {
                comment = value;
                OnPropertyChanged("Comment");
            }
        }
        /// <summary>
        /// Gets or sets the resource the element uses.
        /// </summary>
        /// <value>The resource.</value>
        public RBResource Resource {
            get { return resource; }
            set {
                resource = value;
                OnPropertyChanged("Resource");
            }
        }

        /// <summary>
        /// Initializes a new <see cref="RBElement"/>.
        /// </summary>
        public RBElement() {
            this.id = -1;
            this.name = string.Empty;
            this.bundleID = string.Empty;
            this.bundleName = string.Empty;
            this.comment = string.Empty;
        }

        /// <summary>
        /// Initializes a new <see cref="RBElement"/>.
        /// </summary>
        /// <param name="id">The ID.</param>
        /// <param name="name">The name.</param>
        /// <param name="bundleId">The bundle ID.</param>
        /// <param name="bundleName">Name of the bundle.</param>
        /// <param name="comment">The comment.</param>
        public RBElement(int id, string name, string bundleId, string bundleName, string comment) {
            this.id = id;
            this.name = name;
            this.bundleID = bundleId;
            this.bundleName = bundleName;
            this.comment = comment;
        }

        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void OnPropertyChanged(string strPropertyName) {
            if(PropertyChanged != null) {
                PropertyChanged(this, new PropertyChangedEventArgs(strPropertyName));
            }
        }
    }
}
